import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import category from '@/views/Category'
import Play from '@/views/Playground'
import SubCategory from '@/views/Category/Sub'

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: Home
      },
      {
        path: '/category/:id',
        component: category
      },
      {
        path: '/subCategory/:id',
        component: SubCategory
      }
    ]
  },
  {
    path: '/play',
    component: Play
  }
//   {
//     path: '/',
//     name: 'Home',
//     component: Home
//   },
//   {
//     path: '/about',
//     name: 'About',
//     // route level code-splitting
//     // this generates a separate chunk (about.[hash].js) for this route
//     // which is lazy-loaded when the route is visited.
//     component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
//   }
]
// createRouter 创建一个路由实例对象
// createWebHashHistory() 执行返回值交给history配置项
const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
